<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
//批量替换脚本，用于优化模块兼容
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'set';
$return=array();
$tabs=array(
	array('op'=>'set','title'=>'内容替换'),
);
if($_RQ['op']=='set'){
	$return['uniacids']=pdo_getall('core_accounts',array('title <>'=>''),array('uniacid','title'));
	$return['item']=array('type'=>0);
	$return['htmls']=array(
			'type'=>'edit',
			'desc'=>'内容替换',
			'post'=>'post',
			'tabs'=>$tabs,
			'edit'=>array(
				array('type'=>'tip','title'=>'[温馨提示]：本替换工具，适合品牌名称批量替换；域名批量替换！'),
				array('type'=>'select','name'=>'uniacid','title'=>'选择要替换的站点','options'=>'uniacids','option_value'=>'uniacid'),
				array('type'=>'radio','name'=>'type','title'=>'替换内容类型','options'=>'types'),
				array('type'=>'checkbox','name'=>'replace','title'=>'勾选替换内容','options'=>'replaces','show'=>array('type'=>array(0))),
				array('type'=>'checkbox','name'=>'replace','title'=>'勾选替换内容','options'=>'replaces2','show'=>array('type'=>array(1))),
				array('type'=>'string_two','title'=>'自定义表段','title1'=>'内容对象表名','name1'=>'table','title2'=>'内容对象字段名','name1'=>'content','show'=>array('type'=>2),'help'=>'不含表前缀；示例：站点文章内容对象表名：core_account_article，内容对象字段名：content'),
				array('type'=>'string','name'=>'seh','title'=>'搜索内容','help'=>'搜索内容：一定要有特点，完整性'),
				array('type'=>'string','name'=>'rep','title'=>'替换内容'),
			),
	);
	$return['types']=array(
			0=>'站点文章',
			1=>'站点商品',
			2=>'自定义表段',
	);
	$return['replaces']=array(
			'content'=>'内容详情',
			'desc'=>'内容描述',
			'title'=>'内容标题',
	);
	$return['replaces2']=array(
			'content'=>'商品详情',
			'subtitle'=>'商品描述',
			'title'=>'商品标题',
	);
	exi($return);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	model('core/content')->replace($post);
	exi('批量替换成功');
}
if($_RQ['op']=='postpici'){
	$page=$_RQ['page'];
	$post=$_RQ['post'];
	$post=cfc('tools')->base64_decode($post,$_SESSION['base_key_str']);
	$post=@json_decode($post,true);
	model('core/content')->replace($post,$page);
	exi('批量替换成功');
}